* Replication code for Multiple Rivals and Leadership Approval: Evidence from Japan
log using lee-multiplerivals.log 

* Experimental analysis
use "japancleaned2.dta", clear

* Table 3
ttest pmapp1recoded, by(polconf)

* Table 4
ttest pmapp1recoded, by(polcoop)

* (Under Table 4) Competence ratings
ttest pmcomp1recoded, by(polconf)
ttest pmcomp1recoded, by(polcoop)

* Table 5
** Model 1
oprobit pmapp1recoded male college age fulltime cons ldp i.polconf
** Model 2
oprobit pmapp1recoded male college age fulltime cons ldp i.polcoop
** Model 3
oprobit pmcomp1recoded male college age fulltime cons ldp i.polconf
** Model 4
oprobit pmcomp1recoded male college age fulltime cons ldp i.polcoop

* Figure 2
gen polconf2=.
replace polconf2=0 if polconf==2
replace polconf2=1 if polconf==1

oprobit pmapp1recoded male college age fulltime cons ldp polconf2

margins, at(polconf2=(0(1)1)) vsquish saving(m1, replace)

use m1.dta, clear
gen counter= _n
keep if counter<3
twoway (bar _margin counter, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub counter, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Strongly Disapprove)" "") ///
	graphregion(color(white)) ///
	title("Strongly Disapprove", size(medlarge)) ///
	legend(off) ///
	saving(m1_strdis.gph, replace)

use m1.dta, clear
gen counter= _n
keep if counter==3 | counter==4
twoway (bar _margin _at, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub _at, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Disapprove)" "") ///
	graphregion(color(white)) ///
	title("Disapprove", size(medlarge)) ///
	legend(off) ///
	saving(m1_dis.gph, replace)
	
use m1.dta, clear
gen counter= _n
keep if counter==7 | counter==8

twoway (bar _margin _at, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub _at, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Approve)" "") ///
	graphregion(color(white)) ///
	title("Approve", size(medlarge)) ///
	legend(off) ///
	saving(m1_appr.gph, replace)
  
use m1.dta, clear
gen counter= _n
keep if counter==9 | counter==10

twoway (bar _margin _at, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub _at, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Strongly Approve)" "") ///
	graphregion(color(white)) ///
	title("Strongly Approve", size(medlarge)) ///
	legend(off) ///
	saving(m1_strapp.gph, replace)

graph combine m1_strdis.gph m1_dis.gph m1_appr.gph m1_strapp.gph, col(4) ///
  subtitle("", size(medsmall)) ///
  graphregion(color(white)) ycommon imargin(0 0 0 0) ///
  note("Note: 95% Confidence Intervals reported.", size(small))  ///
  saving(m1_total.gph, replace) 
  
* Figure 3
use "japancleaned2.dta", replace

gen polcoop2=.
replace polcoop2=0 if polcoop==2
replace polcoop2=1 if polcoop==1

oprobit pmapp1recoded male college age fulltime cons ldp polcoop2

margins, at(polcoop2=(0(1)1)) vsquish saving(m2, replace)

use m2.dta, clear
gen counter= _n
keep if counter<3
twoway (bar _margin counter, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub counter, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Strongly Disapprove)" "") ///
	graphregion(color(white)) ///
	title("Strongly Disapprove", size(medium)) ///
	legend(off) ///
	saving(m2_strdis.gph, replace)

use m2.dta, clear
gen counter= _n
keep if counter==3 | counter==4
twoway (bar _margin _at, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub _at, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Disapprove)" "") ///
	graphregion(color(white)) ///
	title("Disapprove", size(medium)) ///
	legend(off) ///
	saving(m2_dis.gph, replace)
	
use m2.dta, clear
gen counter= _n
keep if counter==7 | counter==8

twoway (bar _margin _at, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub _at, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Approve)" "") ///
	graphregion(color(white)) ///
	title("Approve", size(medium)) ///
	legend(off) ///
	saving(m2_appr.gph, replace)
  
use m2.dta, clear
gen counter= _n
keep if counter==9 | counter==10

twoway (bar _margin _at, sort color(gs11) barw(.5)) ///
    (rcap _ci_lb _ci_ub _at, sort pstyle(ci) color(black) lw(medthick)), ///
    xlabel(1 "Lesser"  2 "Bigger", labsize(small)) ///
	ylabel(0(.1)0.5) ///
	xtitle("Threat Levels") ///
	ytitle("Pr(Strongly Approve)" "") ///
	graphregion(color(white)) ///
	title("Strongly Approve", size(medium)) ///
	legend(off) ///
	saving(m2_strapp.gph, replace)

graph combine m2_strdis.gph m2_dis.gph m2_appr.gph m2_strapp.gph, col(4) ///
  subtitle("", size(medsmall)) ///
  graphregion(color(white)) ycommon imargin(0 0 0 0) ///
  note("Note: 95% Confidence Intervals reported.", size(small))  ///
  saving(m2_total.gph, replace) 

  
* Figure 4
use "japancleaned2.dta", replace

twoway hist statea if statea<6, title("State A") percent discrete start(1) saving(statea.gph, replace) 
twoway hist stateb if stateb<6, title("State B") percent discrete start(1) saving(stateb.gph, replace) 
graph combine statea.gph stateb.gph, /// 
row(1) ycommon  title("What countries do you think of?") 


* Observational analysis
use jpappterr2014nomiss.dta, clear

* Figure 5
twoway line approval mdate, ///
 title("", size(medium)) ///
 ytitle("Approval Ratings") ///
 xtitle("Date (Monthly)") 
 
* Figure 6
twoway line jcmo mdate, ///
 title("Japan to China", size(medium)) ///
 ytitle("Net-Cooperation") ///
 xtitle("Date (Monthly)") name(jcmo, replace)
 
twoway line cjmo mdate, ///
 title("China to Japan", size(medium)) ///
 ytitle("Net-Cooperation") ///
 xtitle("Date (Monthly)") name(cjmo, replace)
 
 twoway line jkmo mdate, ///
 title("Japan to South Korea", size(medium)) ///
 ytitle("Net-Cooperation") ///
 xtitle("Date (Monthly)") name(jkmo, replace)
 
twoway line kjmo mdate, ///
 title("South Korea to Japan", size(medium)) ///
 ytitle("Net-Cooperation") ///
 xtitle("Date (Monthly)") name(kjmo, replace)
 
graph combine jcmo cjmo jkmo kjmo, t("") ycommon rows(2)
 

* Table 6
* Model 1
regress approval L.approval jcmo cjmo unemployment cpi newcabinet
estat ic
estimates store m1
predict res1, residuals
wntestq res1

* Model 2
regress approval L.approval jcmo L.cjmo unemployment cpi newcabinet 
estat ic
estimates store m2
predict res2, residuals
wntestq res2

* Model 3
regress approval L.approval jkmo kjmo unemployment cpi newcabinet 
estat ic
estimates store m3
predict res3, residuals
wntestq res3

* Model 4
regress approval L.approval jkmo L.kjmo unemployment cpi newcabinet 
estat ic
estimates store m4
predict res4, residuals
wntestq res4

log close
translate lee-multiplerivals.log lee-multiplerivals.pdf 
